<?php

use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

require __DIR__ . '/../../vendor/autoload.php';

$config = require(__DIR__ . '/../config.php');
$connection = new AMQPStreamConnection(
    $config['host'],
    $config['port'],
    $config['user'],
    $config['password'],
    $config['vhost']
);

$channel = $connection->channel();

const NORMAL_EXCHANE = 'normal_exchange';

$channel->exchange_declare(NORMAL_EXCHANE, 'direct');

foreach(range(0, 10) as $index) {
    $msg = new AMQPMessage('test' . $index, []);
    $channel->basic_publish($msg, NORMAL_EXCHANE, 'rk_normal');
    echo "send msg: ".$index . PHP_EOL;
}